<script>
export default{
    name:"mask",
    props:{
        title:{
            require:true,
            type:String
        },
        screen:{
            type:Boolean,
            value:false,
        },
        duration:{
            type:Number,
            value:2000,
        },
        type:{
            type:String,
            value:"tip"
        }
    },
    data(){
        return{
            infoData:{
                title:'',
                screen:false,
                duration:2000,
                type:'tip'
            },
            maskData:{
                show:false,
                clear:null,
            }
        }
    },
    methods:{
        showMask(info){
            this.infoData = (info);
                this.maskData.show = true;
                this.hideMask();
            // globalMethod((info:any)=>{
            //     infoData = reactive<Person>(info);
            //     maskData.clear = setTimeout(()=>{
            //         maskData.show = true;
            //     },infoData.duration);
            // })
        },
        hideMask(){
            clearTimeout(this.maskData.clear);
            this.maskData.clear = setTimeout(()=>{
                this.maskData.show = false;
            },this.infoData.duration);
        }
    }
}
</script>
<template>
    <div class="mask" v-if="maskData.show" :class="[infoData.screen?'disableClick':'']">
        <div class="tip" :class="[infoData.type]">
            {{ infoData.title }}
        </div>
    </div >
</template>
<style lang="scss">
.mask{
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    .tip{
        text-align: center;
        padding: v(13) v(30);
        display: inline-block;
        background: rgba(0,0,0,0.44);
        border-radius: v(43);
        font-size: v(30);
        color: #FFFFFF;
        animation: show 0.3s linear;
    }
    .success{
        background: rgb(0, 225, 15);
    }
    .error{
        background: rgb(235, 5, 5);
    }
}
.disableClick{
    width: 100%;
    height: 100%;
}
@keyframes show{
    0%{transform: scale(0.5);}
    100%{transform: scale(1);}
}
</style>